package com.exam.common.advice;

import com.exam.common.enums.ExceptionEnum;
import com.exam.common.exception.ExamException;
import com.exam.common.vo.ExceptionResult;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;


/**
 * @ClassName : ExceptionHandler
 * @Description : 通用异常处理器
 * @Author : WHB
 */

@ControllerAdvice
public class ExceptionHandler {

    @org.springframework.web.bind.annotation.ExceptionHandler(ExamException.class)
    public ResponseEntity<ExceptionResult> Exception(ExamException e){
        ExceptionEnum em = e.getExceptionEnum();
        return ResponseEntity.status(em.getCode()).body(new ExceptionResult(e.getExceptionEnum()));
    }

}
